package com.cskaoyan.bean.bo.goods;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import net.sf.json.JSONArray;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author: 冯子靖
 * @Description:
 * @Date: 2022/7/20 9:21
 */
@Data
public class AdminGoodsGoodsUpdateBO {
    private Integer id;

    private String goodsSn;

    private String name;

    private Integer categoryId;

    private Integer brandId;

    private String gallery;

    private String keywords;

    private String brief;

    private Boolean isOnSale;

    private String picUrl;

    private Boolean isNew;

    private Boolean isHot;

    private String unit;

    private BigDecimal counterPrice;

    private BigDecimal retailPrice;

    private String shareUrl;

    private Integer sortOrder;

    private String detail;

    private Date addTime;

    private Date updateTime;

    private boolean deleted;



    public void setGallery(List<String> gallery) {
        if (gallery.size() < 1) {
            this.gallery = "";
        } else {
            this.gallery = JSONArray.fromObject(gallery).toString();
        }
    }
    public Date getAddTime() {
        return addTime;
    }

    public void setAddTime(String addTime) {
        try {
            this.addTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(addTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        try {
            this.updateTime = this.addTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(updateTime);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}
